package com.ruoyi.scale.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.scale.domain.ScaleCategory;
import com.ruoyi.scale.mapper.ScaleCategoryMapper;
import com.ruoyi.scale.service.IScaleCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 量定义Service业务层处理
 *
 * @author dais
 * @date 2023-09-03
 */
@Service
public class ScaleCategoryServiceImpl implements IScaleCategoryService {
    @Autowired
    private ScaleCategoryMapper scaleCategoryMapper;

    /**
     * 查询量定义
     *
     * @param categoryId 量定义主键
     * @return 量定义
     */
    @Override
    public ScaleCategory selectScaleCategoryByCategoryId(Long categoryId) {
        return scaleCategoryMapper.selectScaleCategoryByCategoryId(categoryId);
    }

    /**
     * 查询量定义列表
     *
     * @param scaleCategory 量定义
     * @return 量定义
     */
    @Override
    public List<ScaleCategory> selectScaleCategoryList(ScaleCategory scaleCategory) {
        return scaleCategoryMapper.selectScaleCategoryList(scaleCategory);
    }

    /**
     * 新增量定义
     *
     * @param scaleCategory 量定义
     * @return 结果
     */
    @Override
    public int insertScaleCategory(ScaleCategory scaleCategory) {
        scaleCategory.setCreateTime(DateUtils.getNowDate());
        return scaleCategoryMapper.insertScaleCategory(scaleCategory);
    }

    /**
     * 修改量定义
     *
     * @param scaleCategory 量定义
     * @return 结果
     */
    @Override
    public int updateScaleCategory(ScaleCategory scaleCategory) {
        scaleCategory.setUpdateTime(DateUtils.getNowDate());
        return scaleCategoryMapper.updateScaleCategory(scaleCategory);
    }

    /**
     * 批量删除量定义
     *
     * @param categoryIds 需要删除的量定义主键
     * @return 结果
     */
    @Override
    public int deleteScaleCategoryByCategoryIds(Long[] categoryIds) {
        return scaleCategoryMapper.deleteScaleCategoryByCategoryIds(categoryIds);
    }

    /**
     * 删除量定义信息
     *
     * @param categoryId 量定义主键
     * @return 结果
     */
    @Override
    public int deleteScaleCategoryByCategoryId(Long categoryId) {
        return scaleCategoryMapper.deleteScaleCategoryByCategoryId(categoryId);
    }
}